package com.blog.admin.controller;

import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class ExceptionController{

	@ExceptionHandler(value =Exception.class)
	public String exceptionHandler(Exception e, HttpServletResponse response){
		int statusCode = response.getStatus();
		if(statusCode == 401){
            return "redirect:/admin/401";
        }else if(statusCode == 404){
            return "redirect:/admin/404";
        }else{
            return "redirect:/admin/500";
        }
    }
}

